import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'
import Main from '../views/Main.vue'
import Posts from '../views/Posts.vue'
import MainPosts from '../views/MainPosts.vue'
import Register from '../components/Register.vue'
import UserDetail from '../components/UserDetail.vue'
import Active from '../components/Active.vue'

import GameZone from '../views/GameZone.vue'
Vue.use(VueRouter)

const routes = [
  {
    path:'/',
    name:'Main',
    redirect:'/main',

  },
  {
    path:'/main',
    name:'Main',
    component:Main,
  },
  {
    path:'/login',
    name:'Login',
    component:Login,//嵌套路由
  },
  {
    path:'/posts/:id',
    name: 'Posts',
    component:Posts,
    props:true
    // meta:{
    //   requireAuth: true
    // }
  },
  {
    path:'/mainposts/:id',
    name: 'MainPosts',
    component:MainPosts,
    props:true,
  },
    {
        path:'/register',
        name: 'Register',
        component:Register,
        props:true,
    },
  {
    path:'/userDetail',
    name: 'UserDetail',
    component:UserDetail,
    props:true,
    meta:{
      requireAuth: true
    }
  },
  {
    path:'/active/:id',
    name: 'Active',
    component:Active,
    props:true,
  }
]

const router = new VueRouter({
  mode: 'history',
  routes
})

export default router
